#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c;int a=0;
	while(!isdigit(c=getchar()));
	do{a=(a<<1)+(a<<3)+(c^48);}while(isdigit(c=getchar()));
	return a;
}
int monsters[100010];
bool cmp(int a,int b){
	return monsters[a]<monsters[b]||monsters[a]==monsters[b]&&a<b;
}
int attack[100010],k_at=0;
int alive[100010],k_al=0;
int main(){
	freopen("duel.in","r",stdin);
	freopen("duel.out","w",stdout);
	int n=read();
	for(int i=0;i<n;i++){
		monsters[i]=read();
		attack[i]=i;
	}
	sort(attack,attack+n,cmp);
	for(int i=0;i<n;i++)alive[i]=attack[i];
	while(k_at<n){
		while(k_at<n&&monsters[attack[k_at]]<=monsters[alive[k_al]])
			k_at++;
		if(k_at<n){
			k_al++;
			k_at++;
		}
	}
	printf("%d",n-k_al);
	return 0;
}
